package com.xueyi.aixihu.mapper;

import com.xueyi.aixihu.entity.po.DataCenterReportInfoPo;
import com.xueyi.aixihu.entity.po.DtNewsSort;
import com.xueyi.aixihu.entity.vo.AxhAuditFinanceLogVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 描述
 *
 * @author 刘梓江
 * @date 2023-12-12 12:00
 */
public interface DataCenterMapper {

    //获取3个地区的报表信息列表
    @Select({
        "<script> ",
            "select t2.pid areaPid,t1.* from (select * from axh_finance where is_valid=1 ) ",
            "t1 left join dt_news_sort t2 on t1.from_to_area_id=t2.id ",
            "where t2.is_valid=1 and t2.pid in (3,4,16) ",
        "</script>"
    })
    List<DataCenterReportInfoPo> selectReportInfoList();
    
    //查询指定区域及月份的报表信息列表
    @Select({
        "<script> ",
        "   select t1.* from (select * from axh_finance where is_valid=1) ",
        "   t1 left join dt_news_sort t2 on t1.from_to_area_id=t2.id ",
        "   where t2.is_valid=1 and t2.pid=#{areaType} ",
        "   and DATE_FORMAT(t1.create_time,'%Y-%m')=#{month} ",
        "</script> ",
    })
    List<DataCenterReportInfoPo> selectReportInfoListByAreaAndMonth(@Param("areaType")Integer areaType,@Param("month")String month);

    //查询指定地区信息列表
    @Select({
        "<script> ",
            "select * from dt_news_sort where pid=#{pid} and is_valid=1  ",
            "order by create_time desc ",
        "</script> ",
    })
    List<DtNewsSort> selectNewsSortByPid(@Param("pid") Integer pid);


    //查询用户操作报表日志信息
    @Select({
        "<script> ",
            "   select t1.* , t2.username from axh_finance_log t1  ",
            "   left join dt_users t2 on t1.command_user_id = t2.id ",
            "   order by create_time desc ",
            "   limit #{startIndex},#{limit} ",
        "</script> ",
    })
    List<AxhAuditFinanceLogVo> selectUserOperationReportLogList(@Param("startIndex") Integer startIndex,@Param("limit") Integer limit);
}
